<?php
  function govt_orders_validation($form) {

    // Check bad character validation

   	chkbadchar($form['field_go_abstract']['und'][0]['value']['#value'], $form['field_go_abstract']['und'][0]['value']['#title'],'field_go_abstract');
    chkbadchar($form['title']['#value'], $form['title']['#title'],'title');
	chkbadchar($form['field_go_keywords']['und'][0]['value']['#value'],$form['field_go_keywords']['und'][0]['value']['#title'],'field_go_keywords');

	distvalidation($form['field_go_district']['und']['#value']);

	// minimum length charcter
  	minilength_validation($form['title']['#value'], 5, $form['title']['#title'], 'title');
  	minilength_validation($form['field_go_keywords']['und'][0]['value']['#value'], 5, $form['field_go_keywords']['und'][0]['value']['#title'],'field_go_keywords');
  	minilength_validation($form['field_go_abstract']['und'][0]['value']['#value'], 5, $form['field_go_abstract']['und'][0]['value']['#title'], 'field_go_abstract');

 	//maximum length validation for Title and Description Field
  	maxlength_validation($form['title']['#value'], 255, $form['title']['#title'], 'title');

	check_date_expire($form['field_go_date']['und'][0]['value']['date']['#value'],$form['field_go_date']['und'][0]['value']['date']['#title']);


  // Form Type validtion
  if ($form['field_go_available_type']['und']['#value'] == 'online') {
    url_validation($form['field_go_available_url']['und'][0]['value']['#value']);
  }

if ($form['field_go_available_type']['und']['#value'] == 'download') {
	$filename = $form['field_go_available_file']['und'][0]['#file'];
	$filename->filename;
    file_upload_validation_D7($filename->filename,$form['field_go_available_type']['und']['#title']);

  }
}

 function govt_orders_presave_validation($node) {
 	$reference_url = $node->field_go_available_url[0]['value'];
	 $node->field_go_available_url[0]['value'] = url_validation($reference_url);
   // $node->field_go_available_url[0]['value'] = url_validation($reference_url);
  } // function form_presave_validation()